package top.zsyle.movie.feign;

import com.baomidou.mybatisplus.mapper.Wrapper;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import top.zsyle.movie.domain.MovieTicket;
import top.zsyle.movie.domain.UserMovie;
import top.zsyle.movie.dto.GetMiddleDto;
import top.zsyle.movie.fallback.MovieServiceFallbackFactory;
import top.zsyle.movie.result.JsonResult;

import javax.validation.Valid;

@FeignClient(value = "service-movie",path = "movieTicket",contextId = "movieService",fallbackFactory = MovieServiceFallbackFactory.class)
public interface MovieService {

    @RequestMapping(value = "/list",method = RequestMethod.GET)
    JsonResult list();

    @RequestMapping(value = "/listNotOverTime",method = RequestMethod.GET)
    JsonResult listNotOverTime(Wrapper<MovieTicket> wrapper);

    @RequestMapping(value = "/{id}",method = RequestMethod.GET)
    JsonResult get(@PathVariable("id")Long id);
    /**
     * 保存和修改中间表
     */
    @RequestMapping(value="/saveMiddle",method= RequestMethod.POST)
    public JsonResult saveOrUpdateMiddle(@RequestBody UserMovie userMovie);

    @RequestMapping(value="/save",method= RequestMethod.POST)
    JsonResult saveOrUpdate(@RequestBody MovieTicket movieTicket);

    @RequestMapping(value = "/userMovie/{id}",method = RequestMethod.GET)
    JsonResult getUserMovie(@PathVariable("id")Long id);

    @RequestMapping(value = "/getMiddleByUserIdAndMovieId",method = RequestMethod.GET)
    JsonResult getMiddleByUserIdAndMovieId(@RequestBody @Valid GetMiddleDto dto);
}
